package net.togogo.controller;

import net.togogo.bean.User;
import net.togogo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired(required = false)
    UserMapper userMapper;

    @GetMapping("/user/{id}")
    public User getUserById(@PathVariable("id") Integer id){
       return userMapper.getUserById(id);
    }

    @GetMapping("/user")
    public User inserUser(User user){
        userMapper.inserUser(user);
        return user;
    }

    @GetMapping("/userList")
    public List<User> userList(){
        return userMapper.userList();
    }
}
